<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Silence
 * Date: 3/8/12
 * Time: 3:50 AM
 * To change this template use File | Settings | File Templates.
 */

require_once('constants.php');
require_once('api.php');

$con = db_prepare();

$sql = "DROP TABLE IF EXISTS `items`";
db_die(mysql_query($sql));

$sql = "CREATE TABLE IF NOT EXISTS `items` (
  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'item id',
  `item` varchar(255) NOT NULL COMMENT 'item name',
  `description` varchar(255) COMMENT 'item description',
  `cost` double NOT NULL DEFAULT 0.00 COMMENT 'actual cost of item',
  `maxR` double NOT NULL DEFAULT 0.00 COMMENT 'maximum reducible of item',
  `budget` double DEFAULT 0.00 COMMENT 'allocated budget for item',
  `pid` bigint(20) NOT NULL COMMENT 'parent of item',
  `source` bigint(20) NOT NULL DEFAULT 0 COMMENT 'source of item',
  PRIMARY KEY (`id`)
)";

db_die(mysql_query($sql));

$data = array();
$data[] = array(1, 'Budget Manager', 'manage all your budget here', 0, 0, 0, 0, 0);
$data[] = array(2, 'Income', 'income folder', 0, 0, 0, 1, 0);
$data[] = array(3, 'Internal Sponsor', 'sponsors from NUS', 0, 0, 0, 2, 0);
$data[] = array(4, 'External Sponsor', 'sponsors not from NUS', 0, 0, 0, 2, 0);
$data[] = array(5, 'NUSSU', 'students union', 0, 0, 2000, 3, 0);
$data[] = array(6, 'NUS Co-Op', 'co-op', 0, 0, 1000, 3, 0);
$data[] = array(7, 'VOXLAB', 'training', 0, 0, 700, 4, 0);
$data[] = array(8, 'DBS-Bank', 'publicity', 0, 0, 1000, 4, 0);
$data[] = array(9, 'SUN Asia Bistro', 'logistics', 0, 0, 200, 4, 0);
$data[] = array(10, 'Morning Sun', 'fun pack', 0, 0, 100, 4, 0);
$data[] = array(11, 'Expenditure', 'expenditure folder', 0, 0, 0, 1, 0);
$data[] = array(12, 'Publicity', 'publicity expenditure', 0, 0, 0, 11, 0);
$data[] = array(13, 'Logistics', 'logistics expenditure', 0, 0, 0, 11, 0);
$data[] = array(14, 'Training', 'training expenditure', 0, 0, 0, 11, 0);
$data[] = array(15, 'Program', 'program expenditure', 0, 0, 0, 11, 0);
$data[] = array(16, 'T-shirt', 't-shirt for 50 people', 700, 0, 700, 15, 0);
$data[] = array(17, 'Games', 'games', 150, 0, 150, 15, 0);
$data[] = array(18, 'Instructor Fee', 'Photoshop Trainer', 1000, 0, 1000, 14, 0);
$data[] = array(19, 'Printing Course Materials', 'Photoshop handbook', 220, 0, 220, 14, 0);
$data[] = array(20, 'Food', '50 people', 895, 0, 895, 13, 0);
$data[] = array(21, 'BBQ Pit', 'BBQ Pit', 35, 0, 35, 13, 4);
$data[] = array(22, 'Hostel Accommodation', 'accommodation for 50 people', 1860, 0, 1860, 13, 3);
$data[] = array(23, 'A1 Poster', '50 pieces', 20, 0, 20, 12, 0);
$data[] = array(24, 'A3 Poster', '10 pieces', 80, 0, 80, 12, 0);

foreach ($data as $val) {
    $id = $val[0];
    $item = "'" . $val[1] . "'";
	$description = "'" . $val[2] . "'";
	$cost = $val[3];
	$maxR = $val[4];
	$budget = $val[5];
	$pid = $val[6];
	$source = $val[7];
    $sql = "INSERT INTO `items` (`id`, `item`, `description`, `cost`, `maxR`, `budget`, `pid`, `source`) VALUES
			($id, $item, $description, $cost, $maxR, $budget, $pid, $source)";
    print $sql;
    db_die(mysql_query($sql));
}

mysql_close($con);